<template>
  <div class="containers">
    <div class="float-img"></div>
    <div class="main">
      <!-- 视频列表 -->
      <div class="video-boxshow-">
        <div class="box-tab">
          <div class="list-box">
            <ul>
              <li>
                <div
                  class="video-boxshow--dom"
                  @click="openVideo(vediourl,0,0,0)"
                  :data-id="vediourl"
                >
                  <div class="video-dom">
                    <video
                      :poster="fengmian"
                      :src="vediourl || null"
                      x5-video-player-fullscreen="true"
                      webkit-playsinline
                      preload="auto"
                    ></video>
                    <div class="video-cover">
                      <img
                        class="video-play"
                        src="http://sucai.suoluomei.cn/sucai_zs/images/20190510165615-heseke_play.png"
                      >
                    </div>
                  </div>
                </div>
              </li>
            </ul>
          </div>
        </div>
      </div>
      <!-- 全屏视频展示 -->
      <div class="video-list" v-if="fullPlayVideo">
        <ul>
          <li @click="closeFullVideo">
            <video
              alt
              :src="bigVideo"
              id="media"
              loop
              x5-video-player-type="h5"
              x5-video-player-fullscreen="true"
              webkit-playsinline
              playsinline
              @click="closeFullVideo"
            ></video>
            <!-- 播放视频 -->

            <!-- 关闭全屏 -->

            <!-- 功能区 -->
            <div class="tool" v-if="false">
              <div class="vote" @click="fabulous">
                <img
                  src="http://sucai.suoluomei.cn/sucai_zs/images/20190226112454-vote.png"
                  alt
                  v-if="hasvote"
                >
                <img
                  src="http://sucai.suoluomei.cn/sucai_zs/images/20190226112454-no-vote.png"
                  alt
                  v-else
                >
              </div>
              <div class="share">
                <img
                  src="http://sucai.suoluomei.cn/sucai_zs/images/20190226112454-share.png"
                  alt
                  @click="share"
                >
              </div>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <div class="loding" v-if="loding">
      <van-loading color="#f44"/>
    </div>
  </div>
</template>

<script>
import { Toast, Notify, Dialog } from 'vant'
export default {
  props: {
    vediourl: {
      type: String,
      default: null,
    },
    fengmian: {
      type: String,
      default: null,
    },
  },
  data() {
    return {
      proValue: 'Index',
      total: '',
      voteTotal: '',
      log: '',
      theurl:
        'http://sucai.suoluomei.cn/sucai_zs/video/20190429191952-%E7%A6%BE%E8%89%B2%E5%8F%AF2.MP4',
      // videoItems: [
      //   {
      //     id: 0,
      //     before_image: 'http://sucai.suoluomei.cn/sucai_zs/video/20190429191952-%E7%A6%BE%E8%89%B2%E5%8F%AF2.MP4'
      //   },
      // ],
      bigVideo: '',
      fullPlayVideo: false,
      showPlayIcon: false,
      hasvote: false,
      listType: 0,
      listTabs: [{ name: '最新参赛' }, { name: '投票排名' }],
      sorttype: 1,
      page: 1,
      pageNumNew: 1,
      AllPage: 2,
      showDrawBox: '',
      recordBoxType: 1,
      runDraw: '',
      loding: false,
      vipid: '',
      addressId: '',
      Votes: '0',
      recordBoxTypeTip: '您与奖品擦肩而过~',
      waringAlert: false,
      isDisabled: false,
      prizeitems: [],
      popupShow: false,
      FabulousIsDisable: 0,
      popList: false,
      baseImg:
        'http://sucai.suoluomei.cn/sucai_zs/images/20190409161502-pop_03.png', // 弹窗背景图
      rowArr: [],
    }
  },
  components: {},
  created() {
    // console.log("caonima")
    // console.log(this.vediourl)
    // this.theurl = this.vediourl
    // console.log(this.theurl)
  },
  activated() {},
  mounted() {
    // 添加监听页面滚动
  },
  methods: {
    // 点击连续关闭弹窗
    popCloseList(index) {
      let that = this
      that.rowArr[index].is_show = 1
      let count = 0
      for (let i in that.rowArr) {
        if (that.rowArr[i].is_show == 1) {
          count++
        }
      }
      if (count == that.rowArr.length) {
        that.popList = false
      }
    },

    // 跳转进来看视频
    // async createSign (candidates_id) {
    //   var res = await createSign(candidates_id)
    //   if (res.errcode == 0) {
    //     this.bigVideo = res.data.candidates_info[0].before_image
    //     this.Votes = res.data.candidates_info[0].vote_num
    //     this.vipid = res.data.candidates_info[0].id
    //     this.addressId = res.data.candidates_info[0].division_id
    //     this.fullPlayVideo = true
    //     this.ShowlVideoBox = true
    //     this.showPlayIcon = true
    //     setTimeout(() => {
    //       this.pauseVideo()
    //     }, 1)
    //   } else {
    //     Notify(res.msg)
    //   }
    // },

    // 点击展开全屏
    openVideo(videoUrl, id, addressId, Votes) {
      this.Votes = Votes
      this.addressId = addressId
      this.vipid = id
      this.bigVideo = videoUrl
      this.showPlayIcon = true
      this.fullPlayVideo = true
      setTimeout(() => {
        this.playVideo()
      }, 1)
    },
    // 关闭全屏
    closeFullVideo() {
      this.fullPlayVideo = false
    },
    // 关闭展示视频
    closeShowlVideo() {
      this.ShowlVideoBox = false
    },
    // 点赞
    fabulous() {
      if (this.FabulousIsDisable == 0) {
        this.FabulousIsDisable = 1
        this.judgeUserIsRegistered()
        setTimeout(() => {
          this.FabulousIsDisable = 0
        }, 5000)
      } else {
        Notify('请勿重复点击')
      }
    },
    // 转发
    share() {
      this.$router.push({ path: '/poster', query: { vipId: this.vipid } })
    },
    // 点击视频暂停
    pauseVideo(event) {
      this.showPlayIcon = true
      event && event.target && event.target.pause()
    },
    // 点击暂停icon播放
    playVideo() {
      this.showPlayIcon = false
      var fullVideo = document.getElementById('media')
      fullVideo.play()
    },
    // 跳转方法
    router(link, kind) {
      if (kind == 1) {
        Notify('暂未开放')
      } else if (kind == 2) {
        window.location.href = apiList.oldIndex
      } else if (kind == 3) {
        window.location.href = apiList.register
      } else {
        this.$router.push({ path: link, query: { reset: kind } })
      }
    },
    // 开启弹窗
    openRecordShow(type, BoxType) {
      if (type) {
        this.showDrawBox = type
      }
      if (BoxType == 1) {
        this.recordBoxType = BoxType
        this.BeautifulactionDrawPrizeLog()
      }
    },
    // 关闭弹窗
    closeDrawBox() {
      this.showDrawBox = ''
    },
    // 开始抽奖
    Draw() {
      this.BeautifulactionDrawPrize(this.vipid)
      this.isDisabled = true
    },
    // 监听页面触底
    handleScroll() {
      // 变量scrollTop是滚动条滚动时，距离顶部的距离
      var scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop
      // 变量windowHeight是可视区的高度
      var windowHeight =
        document.documentElement.clientHeight || document.body.clientHeight
      // 变量scrollHeight是滚动条的总高度
      var scrollHeight =
        document.documentElement.scrollHeight || document.body.scrollHeight
      // 滚动条到底部的条件
      if (scrollTop + windowHeight == scrollHeight) {
        if (this.pageNumNew < this.AllPage) {
          this.loding = true
          this.pageNumNew++
          this.SelectCandidatesData(this.sorttype, this.pageNumNew, 1)
        }
      }
    },
  },
}
</script>

<style lang="less" scoped>
.containers {
  width: 9rem;
  background-color: #f1f1f1;
  .float-img {
    position: fixed;
    bottom: 5rem;
    right: 0.5rem;
    z-index: 500;
    img {
      width: 5rem;
    }
  }
  .main {
    background-color: #f1f1f1;
    .poster {
      position: relative;
      width: 100%;
      background-color: #fff;

      .rules {
        display: -webkit-inline-flex;
        display: inline-flex;
        align-items: center;
        position: absolute;
        top: 0;
        right: 0;
        padding: 0.1rem 0.8rem;
        background-image: url('http://sucai.suoluomei.cn/sucai_zs/images/20190226093613-border.png');
        background-size: 100% 100%;
        background-position: center;
        background-repeat: no-repeat;
        font-size: 0.6rem;
        color: #fff;
      }

      .activity-rules {
        top: 1rem;
      }

      .send-ticket-rules {
        top: 3rem;
      }

      .first-hf {
        top: 5rem;
      }

      img {
        display: block;
        width: 100%;
      }

      .data-search {
        width: 100%;
        height: 8rem;

        .data-list {
          display: -webkit-inline-flex;
          display: inline-flex;
          align-items: center;
          width: 100%;
          height: 60%;

          ul {
            display: -webkit-inline-flex;
            display: inline-flex;
            width: 100%;

            li {
              width: 33.33%;
              text-align: center;

              p {
                padding: 0.2rem 0;
                width: 100%;
                color: #777;
                font-size: 0.6rem;
                font-weight: 500;

                span {
                  color: #333;
                  font-size: 1.1rem;
                }
              }
            }

            li:nth-of-type(2) {
              border-left: #ff6666 1px solid;
              border-right: #ff6666 1px solid;
            }
          }
        }

        .search {
          position: relative;
          display: -webkit-inline-flex;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          -webkit-justify-content: center;
          width: 100%;
          height: 40%;

          img {
            position: absolute;
            right: 10%;
            top: 50%;
            margin-top: -0.7rem;
            width: 1.4rem;
            height: 1.4rem;
          }

          input {
            width: 90%;
            height: 70%;
            border: 1px solid #ff6666;
            border-radius: 50rem;
            text-align: center;
            outline: none;
          }
        }
      }
    }

    .video-boxshow- {
      background-color: #fff;

      .box-tab {
        width: 8rem;

        .list-box {
          width: 8rem;
        }
      }

      ul {
        display: -webkit-inline-flex;
        display: inline-flex;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
        width: 8rem;

        li {
          position: relative;
          width: 8rem;
          height: 10rem;
          overflow: hidden;
          margin-right: 1rem;

          .video-boxshow--dom {
            position: relative;
            width: 8rem;
            height: 100%;

            .video-dom {
              position: absolute;
              top: 0;
              left: 0;
              height: 100%;
              overflow: hidden;

              video {
                width: 100%;
                height: 100%;
                object-fit: cover;
              }

              .video-cover {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                z-index: 10;

                .video-play {
                  position: absolute;
                  top: 50%;
                  left: 50%;
                  transform: translate(-50%, -50%);
                  width: 2rem;
                  height: 2rem;
                  z-index: 11;
                }
              }
            }

            .contestant {
              position: absolute;
              bottom: 0;
              left: 0;
              display: -webkit-inline-flex;
              display: inline-flex;
              justify-content: space-between;
              -webkie-justify-content: space-between;
              align-items: center;
              -webkie-align-items: center;
              -ms-flex-wrap: wrap;
              flex-wrap: wrap;
              width: 100%;
              height: 20%;

              span {
                margin-left: 0.5rem;
                padding: 0 0.2rem;
                font-size: 0.7rem;
                border-radius: 0.2rem;
                border: 1px solid #ff6666;
                color: #777777;
              }

              a {
                margin-right: 0.5rem;
                font-size: 0.8rem;
                color: #333;
              }

              .address-num {
                display: -webkit-inline-flex;
                display: inline-flex;
                justify-content: space-between;
                -webkie-justify-content: space-between;
                align-items: center;
                -webkie-align-items: center;
                padding-right: 0.5rem;
                width: 100%;
                text-align: right;

                p {
                  font-size: 0.6rem;
                }

                p:nth-of-type(1) {
                  margin-left: 0.5rem;
                }

                b {
                  color: #ff4e4e;
                  font-size: 0.8rem;
                }
              }
            }
          }
        }
      }
    }

    .video-list {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 2001;
      overflow: scroll;
      background-color: #000;

      ul {
        width: 100%;
        height: 100%;

        li {
          position: relative;
          width: 100%;
          height: 100%;
          overflow: hidden;
          display: -webkit-flex;
          display: flex;
          justify-content: center;
          -webkie-justify-content: center;
          align-items: center;
          -webkie-align-items: center;

          video {
            width: 100%;
            object-fit: cover;
          }

          .play {
            position: absolute;
            top: calc(50% - 2rem);
            left: calc(50% - 2rem);
            width: 4rem;
            height: 4rem;
          }

          .close {
            position: absolute;
            top: 2rem;
            left: 2rem;
            width: 2rem;
            height: 2rem;
          }

          .tool {
            display: -webkit-flex;
            display: flex;
            justify-content: center;
            -webkie-justify-content: center;
            align-items: center;
            -webkie-align-items: center;
            flex-wrap: wrap;
            -ms-flex-wrap: wrap;
            position: absolute;
            top: 50%;
            right: 0.5rem;
            width: 4rem;
            z-index: 1001;

            .vote {
              display: -webkit-flex;
              display: flex;
              justify-content: center;
              -webkie-justify-content: center;
              align-items: center;
              -webkie-align-items: center;
              flex-wrap: wrap;
              -ms-flex-wrap: wrap;
              width: 100%;

              img {
                width: 1.5rem;
                height: 1.5rem;
              }

              p {
                padding: 0.2rem 0;
                width: 100%;
                text-align: center;
                color: #fff;
                font-size: 0.8rem;
              }
            }

            .share {
              display: -webkit-flex;
              display: flex;
              justify-content: center;
              -webkie-justify-content: center;
              align-items: center;
              -webkie-align-items: center;
              flex-wrap: wrap;
              -ms-flex-wrap: wrap;
              margin-top: 1.5rem;
              width: 100%;

              img {
                width: 1.5rem;
                height: 1.5rem;
              }
            }
          }
        }
      }
    }
  }
}
</style>
